using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using System.Runtime.InteropServices;

namespace XnaDevRu.BulletX.Dynamics
{
	//1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints.
	public class SolverConstraint
	{
		private Vector3 _relpos1CrossNormal = new Vector3();
		private Vector3 _relpos2CrossNormal = new Vector3();
		private Vector3 _contactNormal = new Vector3();
		private Vector3 _angularComponentA = new Vector3();
		private Vector3 _angularComponentB = new Vector3();

		private float _appliedVelocityImpulse;
		private int _solverBodyIdA;
		int _solverBodyIdB;
		private float _friction;
		private float _restitution;
		private float _jacDiagABInv;
		private float _penetration;
		private float _appliedImpulse;

		private SolverConstraintType _constraintType = SolverConstraintType.Contact;
		private int _frictionIndex;
		private int[] _unusedPadding = new int[2];

		public Vector3 RelPosACrossNormal { get { return _relpos1CrossNormal; } set { _relpos1CrossNormal = value; } }
		public Vector3 RelPosBCrossNormal { get { return _relpos2CrossNormal; } set { _relpos2CrossNormal = value; } }
		public Vector3 ContactNormal { get { return _contactNormal; } set { _contactNormal = value; } }
		public Vector3 AngularComponentA { get { return _angularComponentA; } set { _angularComponentA = value; } }
		public Vector3 AngularComponentB { get { return _angularComponentB; } set { _angularComponentB = value; } }

		public float AppliedVelocityImpulse { get { return _appliedVelocityImpulse; } set { _appliedVelocityImpulse = value; } }
		public int SolverBodyIdA { get { return _solverBodyIdA; } set { _solverBodyIdA = value; } }
		public int SolverBodyIdB { get { return _solverBodyIdB; } set { _solverBodyIdB = value; } }
		public float Friction { get { return _friction; } set { _friction = value; } }
		public float Restitution { get { return _restitution; } set { _restitution = value; } }
		public float JacDiagABInv { get { return _jacDiagABInv; } set { _jacDiagABInv = value; } }
		public float Penetration { get { return _penetration; } set { _penetration = value; } }
		public float AppliedImpulse { get { return _appliedImpulse; } set { _appliedImpulse = value; } }

		public SolverConstraintType ConstraintType { get { return _constraintType; } set { _constraintType = value; } }
		public int FrictionIndex { get { return _frictionIndex; } set { _frictionIndex = value; } }
		public int[] UnusedPadding { get { return _unusedPadding; } set { _unusedPadding = value; } }

		public enum SolverConstraintType
		{
			Contact = 0,
			Friction,
		}
	}
}
